pub enum FourBits {
    B0000 = 0b0000,
    B0001 = 0b0001,
    B0010 = 0b0010,
    B0011 = 0b0011,
    B0100 = 0b0100,
    B0101 = 0b0101,
    B0110 = 0b0110,
    B0111 = 0b0111,
    B1000 = 0b1000,
    B1001 = 0b1001,
    B1010 = 0b1010,
    B1011 = 0b1011,
    B1100 = 0b1100,
    B1101 = 0b1101,
    B1110 = 0b1110,
    B1111 = 0b1111,
}

impl FourBits {
    pub fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
        use FourBits::*;

        match (x as u8) << 3 | (y as u8) << 2 | (z as u8) << 1 | (w as u8) << 0 {
            0b0000 => B0000,
            0b0001 => B0001,
            0b0010 => B0010,
            0b0011 => B0011,
            0b0100 => B0100,
            0b0101 => B0101,
            0b0110 => B0110,
            0b0111 => B0111,
            0b1000 => B1000,
            0b1001 => B1001,
            0b1010 => B1010,
            0b1011 => B1011,
            0b1100 => B1100,
            0b1101 => B1101,
            0b1110 => B1110,
            0b1111 => B1111,
            _ => panic!("Unexpected mask value"),
        }
    }
}
